package com.hmall.api.client;


import com.hmall.api.client.fallback.ItemClientFallbackFactory;
import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

/**
 * 商品微服务的远程调用的feign接口
 */
//仅对当前的FeignCLient日志配置生效
@FeignClient(value = "item-service"
        //服务降级
        ,fallbackFactory = ItemClientFallbackFactory.class
//        ,configuration = DefaultFeignConfig.class
)
public interface ItemClient {
    /**
     * 定义查询的方法
     */
    @GetMapping("/items")
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") List<Long> ids);
    @PutMapping("/items/stock/deduct")
    public void deductStock(@RequestBody Collection<OrderDetailDTO> items);
    @GetMapping("{id}")
    public ItemDTO queryItemById(@PathVariable("id") Long id);
    @PutMapping
    public void updateItem(@RequestBody ItemDTO item);
}
